package ca.cbc.giscommon.entity;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Table(name = "category")
public class Category implements Cloneable, Serializable {

    private static final long serialVersionUID = 5516673177315540722L;
	private long id;
	private String name;
	
	public Category() {}
	
	public Category(String name) {
		this.setName(name);
	}
		
	@Override
	public Category clone() throws CloneNotSupportedException {
		return (Category) super.clone();
	}
	
	public boolean equals(Object obj) {
		if(obj.getClass().equals(Category.class) && ((Category)obj).getId() == this.getId()) {
			return true;
		}
		return false;
	}
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	public long getId() {
		return id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setId(long id) {
		this.id = id;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String toString() {
		return new StringBuffer("Category {id:").append(id)
				.append(", name:").append(name).append("}")
				.toString();
	}
}
